home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / lists / opened / opened.asm next >
Assembly Source File  |  1990-07-30  |  4KB  |  181 lines

  1.     name    OPENED
  2.  
  3.     title    OPENED -- program to find who has a file open
  4. ;
  5. START    segment    word public 'CODE'
  6.     assume    CS:START,DS:START,SS:START,ES:START
  7.  
  8.     org    100h
  9. begin:
  10.     jmp    past_name
  11.     db    'OPENED V1.0'
  12. past_name:
  13. ;
  14. ;    First move to command tail to the request buffer and do the request
  15. ;
  16.     mov    si,81h        ; location of tail
  17.     mov    di,offset file_name    ; file name within command
  18.     mov    cx,1        ; byte counter
  19. move_loop:
  20.     lodsb            ; get next character
  21.     cmp    al,13
  22.     je    end_of_name
  23.     cmp    al,' '
  24.     jz    move_loop
  25.     cmp    al,08
  26.     jz    move_loop
  27.     inc    cl
  28.     stosb
  29.     jmp    move_loop
  30. end_of_name:
  31.     mov    file_name_length,cl
  32.     add    cl,(7-2)    ; add length of buffer header - 2
  33.     mov    si,offset get_conn_req
  34.     mov    word ptr [si],cx            ; record buffer length        
  35.     mov    al,0        ; terminate with a zero
  36.     stosb            ; add to file name
  37.     mov    ah,0e3h        ; request function code
  38.     mov    di,offset get_conn_rep
  39.     int    21h
  40. ;
  41. ;    Check for correct return code
  42. ;
  43.     or    al,al
  44.     jz    found_file
  45.     mov    dx,offset error_msg
  46.     mov    ah,9
  47.     int    21h
  48.     jmp    done
  49. ;
  50. ;    Put up the basic information
  51. ;
  52. found_file:
  53.     mov    si,offset get_conn_rep
  54.     mov    al,[si+3]    ; in use count
  55.     call    to_ascii
  56.     mov    using_num,ax
  57. ;
  58.     mov    al,[si+5]    ; open count
  59.     call    to_ascii
  60.     mov    open_num,ax
  61. ;
  62.     mov    ah,9
  63.     mov    dx,offset using
  64.     int 21h            ; put up used message
  65.     mov    ah,9
  66.     mov    dx,offset open
  67.     int 21h            ; put up opened message
  68. ;
  69. ;    Go through all the connections and get their names
  70. ;
  71.     mov    cl,records
  72.     cmp    cl,0
  73.     je    done
  74.     mov    ch,0        ; get the number of records
  75.     mov    si,offset get_name_req
  76.     mov    di,offset get_name_rep
  77.     mov    bx,offset get_conn_rep+19    ; first connection number
  78.     mov    dx,offset get_name_rep+8    ; user name
  79. ;
  80. conn_loop:
  81.     mov    al,byte ptr [bx]    ; get connection number
  82.     mov    conn_out,al        ; load connection number
  83.     mov    ah,0e3h
  84.     int    21h            ; request connections information
  85. ;
  86.     mov    word ptr[di+54],0a0dh    ; CRLF
  87.     mov    byte ptr[di+56],'$'    ; terminate name for function 9
  88.     mov    ah,9
  89.     int    21h            ; print the name
  90. ;
  91.     add    bx,6            ; jump to next connection
  92.     loop    conn_loop
  93. ;
  94. done:
  95.     mov    ah,0
  96.     int    21h
  97. ;
  98. ;------------------------------------------------------------------------------
  99. ;TO_ASCII Translates the byte in al into two ascii digits in AX
  100. ;------------------------------------------------------------------------------
  101. to_ascii    proc near
  102.     mov    ah,0        ;just to be sure
  103. to_ascii_5:
  104.     sub    al,10
  105.     jc    to_ascii_10
  106.     inc    ah
  107.     jmp    to_ascii_5
  108. ;
  109. to_ascii_10:
  110.     add    al,10
  111.     add    ax,3030h
  112. ;
  113.     xchg    al,ah
  114.     cmp    al,30h
  115.     jne    to_ascii_20
  116.     mov    al,' '
  117. to_ascii_20:
  118.     ret
  119. to_ascii    endp
  120. ;
  121. ;    Message strings
  122. ;
  123. using:    db    13,10,'File use count:  '
  124. using_num    label word
  125.     db    '00$'
  126. open:    db    13,10,'File open count: '
  127. open_num    label word
  128.     db    '00',13,10,'$'
  129. ;
  130. ;    Get connection buffers
  131. ;
  132. get_conn_req:
  133.     dw    ?        ; req buffer len
  134.     db    0dch        ; function code
  135.     dw    0        ; last record
  136.     db    0        ; directory handle
  137. file_name_length:
  138.     db    ?        ; file name length
  139. file_name:
  140.     db     256 dup(?)    ; file name
  141. ;
  142. get_conn_rep:
  143.     dw    512        ; rep buffer length
  144.     dw    ?        ; use count
  145.     dw    ?        ; open count
  146.     dw    ?        ; open for read count
  147.     dw    ?        ; open for write count
  148.     dw    ?        ; deny read count
  149.     dw    ?        ; deny write count
  150.     dw    ?        ; next request record
  151.     db    ?        ; locked
  152. records:
  153.     db    ?        ; records
  154. ;
  155.     db    500 dup(?)    ; remainder of records
  156. ;
  157. get_name_req:
  158.     dw    3        ; buffer length - 2
  159.     db    16h
  160. conn_out:
  161.     db    ?
  162. ;
  163. get_name_rep:
  164.     dw    get_name_len    ; buffer length - 2
  165.     dd    ?        ; object ID
  166.     dw    ?        ; object type
  167.     db    48 dup (?)    ; object name
  168.     db    7 dup (?)    ; object login time
  169. get_name_len = ($-get_name_req)-2
  170.  
  171. error_msg:
  172.     db    13,10,'Unable to open file',13,10,
  173.     db    13,10,13,10,'Did you give the netware volume?',13,10,'$'
  174. START    ends
  175.  
  176.     end    begin
  177.  
  178.  
  179.  
  180.     
  181.